<?php

use Illuminate\Support\Facades\Route;
use \App\Modules\Apicrzs\Http\Middleware\ApiCheckAuth;
use \App\Modules\Apicrzs\Http\Middleware\CheckUserAuthMiddleware;

Route::prefix('apicrzs')
    ->group(function() {
        Route::get('junda', 'PublicController@junda');
        Route::get('basic_config', 'PublicController@getMallBasicConfig');
        Route::get('get_agreement', 'PublicController@getAgreementType');
        Route::get('get_area', 'System\SystemAreaController@getAreaTree');
        Route::post('error_log', 'System\SystemController@wxErrorLog');
        Route::get('version', 'System\SystemController@versionLogs');
//        Route::get('get_agreement', 'System\PolicyController@getAgreementType');

        Route::get('getFileSign', 'UploadController@getFileSign');

        Route::prefix('system')->group(function () {
            Route::post('systemInfo', 'System\SystemController@systemInfo');
        });

        Route::prefix('wechat')->group(function () {
            // Route::get('silence_auth', 'Auth\LoginControllers@silenceAuth');
            Route::get('silence_auth', 'Wechat\AuthController@silenceAuth');
            Route::get('auth_login', 'Auth\LoginControllers@auth_login');
        });

        Route::prefix('gq')->group(function () {
            Route::get('source', 'Public\EquipmentController@getSource');// 来源
            Route::get('device', 'Public\EquipmentController@device');// 来源
//            Route::prefix('device')->group(function () {
//                return view('device');
//            });
        });
        // 授权登录
        Route::prefix('routine')->group(function () {
            //小程序页面登录类型
            Route::get('auth_type', 'Wechat\AuthController@authType');
            //小程序授权登录
            Route::get('auth_login', 'Auth\LoginControllers@authLogin');
            //小程序授权绑定手机号
            Route::post('auth_binding_phone', 'Wechat\AuthController@authBindingPhone');
            //手机号直接登录
            Route::get('phone_login', 'Auth\LoginControllers@phoneLogin');
            //小程序授权后绑定手机号
            Route::post('binding_phone', 'Auth\LoginControllers@BindingPhone');
        });
        //支付回调
        Route::prefix('pay')->group(function () {
            Route::prefix('junda')->group(function () {
                Route::get('notify', 'Wechat\PayNotifyControllers@notify');
            });
            Route::match(['GET','POST'],'notify/{type}', 'Wechat\PayNotifyControllers@notify');


            Route::prefix('alipay')->group(function () {
                Route::get('notifyConsume', 'Wechat\PayNotifyControllers@notifyConsume');
                Route::get('notifyRecharge', 'Wechat\PayNotifyControllers@notifyRecharge');
            });
            Route::get('auth_login', 'Auth\LoginControllers@auth_login');
        });




        Route::prefix('auth')->group(function () {
            Route::post('login', 'LoginController@login');
            Route::post('verifykey', 'LoginController@verifyKey');//获取发短信的key
            Route::post('verifycode', 'LoginController@verifyGetCode');//获取发短信的key
            Route::post('register', 'LoginController@register');//注册
            Route::post('retrieve', 'LoginController@retrieve');//注册
            Route::prefix('register')->group(function () {
                Route::post('reset', 'LoginController@resetLogin');//注册
                Route::post('verify', 'LoginController@registerVerify');//注册
                Route::post('register', 'LoginController@registerVerify');//注册
            });
        });



        Route::middleware([ApiCheckAuth::class])->group(function () {
            Route::get('banners', 'System\BannerController@getSelectLists');
            Route::prefix('user')->group(function () {
                Route::get('detail', 'UsersController@details');
                Route::put('edit', 'UsersController@update');
                Route::put('binding_phone', 'UsersController@binding_phone');
                Route::put('binding', 'UsersController@binding');
                Route::get('cancel', 'UsersController@cancel');
                Route::post('verification', 'UsersController@verification');
                //用户积分
                Route::prefix('score')->group(function () {
                    Route::get('list', 'Buy\BuyScoreController@lists');
                    Route::get('sum', 'Buy\BuyScoreController@getCountSum');
                    Route::get('usable', 'Buy\BuyScoreController@usable');//提现记录
                    Route::get('statistics', 'Buy\BuyScoreController@statistics');//我的统计
                    Route::post('take', 'Buy\BuyScoreController@take');// 提现
                    Route::get('apparatus', 'Buy\BuyScoreController@getUserApparatusScoreList');// 昨日
                    Route::get('accumulate', 'Buy\BuyScoreController@getAccumulateScoreList');// 提现
                });
                Route::prefix('extract')->group(function () {
                    Route::get('list', 'Buy\UserExtractController@extractList');
                    Route::post('cash', 'Buy\UserExtractController@cashCreate');// 提现
                });
                // 用户银行卡
                Route::prefix('bank')->group(function () {
                    Route::get('list', 'UserBankController@lists');
                    Route::get('getSelectLists', 'UserBankController@getSelectLists');
                    Route::get('detail', 'UserBankController@detail');
                    Route::post('create', 'UserBankController@create');
                    Route::put('update', 'UserBankController@update');
                    Route::delete('delete', 'UserBankController@delete');
                });
                // 用户vip
                Route::prefix('vip')->group(function () {
                    Route::get('list', 'UserVipController@getVipList');//vip详情
                    Route::get('detail', 'UserVipController@getUserVipInfo');//vip详情
                    Route::post('redeem', 'UserVipController@userVipRedeem');//开通VIP
                });
                // 用户水机  - 2025-04-08
                Route::prefix('apparatus')->group(function () {
                    Route::get('lists', 'Buy\WaterDeviceControllers@lists');//水机列表
                    Route::get('detail', 'Buy\WaterDeviceControllers@detail');//水机详情
                    Route::post('redeem', 'Buy\WaterDeviceControllers@redeem');//添加水机
                    Route::get('count', 'Buy\WaterDeviceControllers@getApparatusCount');//添加水机
                });

            });

            //购买水机
            Route::prefix('buy')->group(function () {
                //银行
                Route::prefix('bank')->group(function () {
                    Route::get('/list', 'BankController@getSelectLists');
                    Route::post('/create', 'BankController@create');// 绑定银行卡/ 认证
                });
                //区域
                Route::prefix('bank')->group(function () {
                    Route::get('/community', 'CommunityController@getSelectLists');
                });
                //区域
                Route::prefix('spread')->group(function () {
                    Route::get('/qrcode', 'Buy\SpreadDeviceController@getQrcode');
                    Route::prefix('device')->group(function () {
                        Route::get('/list', 'Buy\SpreadDeviceController@getList');
                        Route::get('/profits', 'Buy\SpreadDeviceController@getProfitLists');
                    });
                });
            });
            //投诉反馈
            Route::prefix('feedback')->group(function () {
                Route::post('/create', 'System\FeedbackController@create');
            });
            Route::prefix('device')->group(function () {
                Route::post('/warranty', 'Intake\DeviceWarrantyController@createWarranty');//设备保修
            });

            // 取水
            Route::prefix('intake')->group(function () {
                // 附近设备
                Route::prefix('device')->group(function () {
                    Route::get('/list', 'Intake\DeviceController@lists'); // 设备列表 + 地图
                    Route::get('/getEquipmentPlan', 'Intake\DeviceController@getEquipmentPlan'); //
                    Route::post('/orderConsume', 'Intake\DeviceController@orderConsume'); //
                    Route::prefix('maintenance')->group(function () {
                        // 设备维保
                        Route::get('/list', 'Intake\DeviceMaintenanceController@lists');
                    });
                });
                //卡券 - 套餐  type 1-水券；2-套餐
                Route::prefix('coupon')->group(function () {
                    Route::get('/lists', 'Intake\CouponController@lists');
                });
                // 用户水卡
                Route::prefix('card')->group(function () {
                    Route::get('/info', 'Intake\UserCardController@getCardInfo');// 查询水卡信息
                    Route::get('/getICBalance', 'Intake\UserCardController@getICBalance');// 查询水卡信息
                    Route::post('/create', 'Intake\UserCardController@create');//  提交绑定水卡
                    Route::post('/electronicCard', 'Intake\UserCardController@createElectronicCardGenInfo');// 申请电子水卡
                    Route::get('/lists', 'Intake\UserCardController@getCardList');// 我的水卡
                    Route::get('/selectLists', 'Intake\UserCardController@getCardSelectLists');// 我的水卡
                    Route::get('/getCardInfo', 'Intake\UserCardController@getOrderCardInfo');// 单个水卡
                    Route::post('/update', 'Intake\UserCardController@update');
                    Route::delete('/delete', 'Intake\UserCardController@deleteBinding');// 我的水卡
                });
                //充值
                Route::prefix('recharge')->group(function () {
                    Route::get('/list', 'Intake\PayRechargeController@lists');// 充值记录
                    Route::post('/order', 'Intake\PayRechargeController@createRechargeOrder');// 充值 订单
                    Route::get('/flowing', 'Intake\PayRechargeController@getSelectFlowingLists');// 充值记录
                });
                //充值
                Route::prefix('pay')->group(function () {
                    Route::post('/create', 'Intake\PayRechargeController@create');// 充值
                    Route::get('/list', 'Intake\PayRechargeController@getSelectLists');// 充值记录
                });
                Route::prefix('waterCards')->group(function () {
                    Route::get('consume', 'Intake\WaterCardController@consume');// 充值记录
                });
                //消费记录
                Route::get('flowing', 'Intake\WxPayController@getSelectLists');// 充值记录

            });
            // 商城
            Route::prefix('mall')->group(function () {
                // 商品列表
                Route::prefix('goods')->group(function () {
                    Route::get('/', 'Mall\GoodsController@lists'); // 商品列表
                    Route::get('/detail', 'Mall\GoodsController@getDetail'); // 商品列表
                    Route::get('/hot', 'Mall\GoodsController@getHotLists'); // 推荐商品
                    Route::prefix('maintenance')->group(function () {
                        // 设备维保
                        Route::get('/list', 'Intake\DeviceMaintenanceController@lists');
                    });
                });
                // 收藏
                Route::prefix('user')->group(function () {
//                    Route::prefix('address')->group(function () {
    //                    category product=普通产品,product_seckill=秒杀产品
//                        Route::get('/', 'Users\UserAddressController@index');
//                    });
                    Route::prefix('address')->group(function () {
    //                    category product=普通产品,product_seckill=秒杀产品
                        Route::get('/', 'Users\UserAddressController@index');
                        Route::post('/create', 'Users\UserAddressController@create');
                        Route::post('/update', 'Users\UserAddressController@update');//修改
                        Route::get('/default', 'Users\UserAddressController@setDefault');//默认地址
                        Route::post('/del', 'Users\UserAddressController@setDel');
                    });
                    // 购物车
                    Route::prefix('cart')->group(function () {
                        Route::get('/', 'Users\UserCartController@index');// 购物车列表
                        Route::get('/count', 'Users\UserCartController@getICBalance');// 购物车数量
                        Route::post('/create', 'Users\UserCartController@createCart');//  添加购物车
                        Route::post('/reset_cart', 'Users\UserCartController@reset_cart');//  修改购物车
                        Route::post('/num', 'Users\UserCartController@getGoodsNum');// 修改购物车数量
                        Route::get('/clear_cart', 'Users\UserCartController@getClearCart');// 清空购物车
                        Route::get('/cart_amount', 'Users\UserCartController@getUserCartAmount');// 购物车 金额
                        Route::post('/change_num', 'Users\UserCartController@getChangeNum');// 购物车 改变数量
                    });
                    // 收藏
                    Route::prefix('collect')->group(function () {
//                    category product=普通产品,product_seckill=秒杀产品
                        Route::get('/list', 'Users\UserCollectController@index');
                        Route::post('/create', 'Users\UserCollectController@create');
                        Route::post('/remove', 'Users\UserCollectController@remove');
                    });
                });

                // 订单
                Route::prefix('order')->group(function () {
                    Route::get('/count', 'Mall\MallGoodsOrderController@getCount');// 订单数量
                    Route::get('/list', 'Mall\MallGoodsOrderController@lists');// 用户订单列表
                    Route::post('/create', 'Mall\MallGoodsOrderController@createOrder');// 创建订单
                    Route::get('/detail', 'Mall\MallGoodsOrderController@getDetail');// 用户订单详情
                    Route::post('/pay', 'Mall\MallGoodsOrderController@pay');// 订单支付
                    Route::post('/cancel', 'Mall\MallGoodsOrderController@cancel');// 订单取消
                    Route::post('/take', 'Mall\MallGoodsOrderController@take');//  确认收货
                    Route::get('/num', 'Mall\MallGoodsOrderController@num');// 修改购物车数量
                    Route::prefix('express')->group(function () {
                        Route::get('/', 'Mall\MallGoodsOrderController@getExpressList');// 订单列表
                    });
                    // 订单
                    Route::prefix('refund')->group(function () {
                        Route::get('/', 'Mall\OrderRefundController@lists');// 用户订单退款列表
                        Route::post('/create', 'Mall\OrderRefundController@createOrder');// 创建退款
                        Route::get('/detail', 'Mall\OrderRefundController@getICBalance');// 退款详情
                        Route::post('/pay', 'Mall\OrderRefundController@pay');// 订单支付
                        Route::post('/cancel', 'Mall\OrderRefundController@cancel');// 取消退款
                        Route::post('/take', 'Mall\OrderRefundController@take');//  确认收货
                        Route::get('/num', 'Mall\OrderRefundController@num');// 修改购物车数量
                        Route::prefix('express')->group(function () {
                            Route::get('/', 'Mall\MallGoodsOrderController@getExpressInfo');// 订单列表
                        });
                    });
                });

            });



        });
    });
